{% extends './layout.html' %} {% block title %} {{ title }} {% endblock %}{% block crumbs %}
<a href="/">首页</a>
<a><cite>小说管理</cite></a>
{% endblock %} {% block body %}
<div class="layout_head">
	<a type="button" class="layui-btn layui-btn-sm" href="/story/add"><i class="layui-icon">&#xe608;</i> 新增小说</a>
</div>
<div class="layout_cont">
	<table class="layui-table">
		<colgroup>
			<col width="120">
			<col>
			<col width="150">
			<col width="150">
			<col width="150">
			<col>
			<col width="100">
			<col width="100">
		</colgroup>
		<thead>
			<tr>
				<th>小说编号</th>
				<th>小说标题</th>
				<th>小说作者</th>
				<th>小说类型</th>
				<th>小说状态</th>
				<th>小说封面</th>
				<th>章节</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody id="storyList">
			{% for item in list %}
			<tr>
				<td>{{ item.bookno }}</td>
				<td>{{ item.bookname }}</td>
				<td>{{ item.bookauthor }}</td>
				<td>{{ item.booktype | bktype }}</td>
				<td>{{ item.bookstatus | status }}</td>
				<td>{{ item.bookimg }}</td>
				<td>
					<a class="layui-btn layui-btn-xs" href="/story/{{item.bookno}}">查看章节</a>
				</td>
				<td>
					<div class="layui-btn-group">
						<a class="layui-btn layui-btn-xs layui-btn-warm" href="/story/edit?id={{item.id}}">编辑</a>
						<button type="button" class="layui-btn layui-btn-xs layui-btn-danger" data-id="{{item.id}}">删除</button>
					</div>
				</td>
			</tr>
			{% endfor %}
		</tbody>
	</table>
</div>
<div id="pageEle" class="layout_page"></div>
{% endblock %} {% block scripts %}
<script type="text/javascript">
	layui.use(['layer', 'laypage', 'custom'], function() {
		var $ = layui.jquery;
		var layer = layui.layer;
		var laypage = layui.laypage;
		var custom = layui.custom;
		laypage.render({
			elem: 'pageEle',
			count: '{{count}}',
			curr: custom.getParam('page') || 1,
			limit: 20,
			layout: ['count', 'prev', 'page', 'next'],
			jump: function(obj, first) {
				if(!first) {
					window.location.href = window.location.href.split('?')[0] + '?page=' + obj.curr
				}
			}
		});
		$('#storyList').on('click', 'button.layui-btn', function() {
			var id = $(this).data('id');
			layer.confirm('是否删除当前管理员？', {
				btnAlign: 'c',
				title: '删除确认'
			}, function(index) {
				$.post('/story/delete', {
					id: id
				},function(data){
					layer.close(index);
					window.location.reload();
				})
			});
		});
	});
</script>
{% endblock %}